<?php
//manager file

switch($_REQUEST['man']) {
	case 'viewRedstars':
	//this allows the manager to view all new redstar lists
	if(isset($_REQUEST['redstar'])) {
		//view individual redstar
		$id = (int) $_REQUEST['redstar'];
		$sql = "SELECT * FROM `t_redstars`,`t_drivers` WHERE `redstar_id` = $id AND `t_drivers`.`driver_id` = `t_redstars`.`driver_id`";
		$result = mysql_query($sql);
		$row = mysql_fetch_assoc($result);
		print "<pre>\n";
		include($row['list_file_name']);
		print "\n</pre>\n";
	} else {
		//view list of redstars
		$sql = "SELECT * FROM `t_redstars`,`t_drivers` WHERE `status` = 0 AND `t_drivers`.`driver_id` = `t_redstars`.`driver_id`";
		$result = mysql_query($sql);
		?>
		<table>
			<tr>
				<th>Driver</th>
				<th>Date</th>
				<th>Time</th>
				<th>View</th>
			</tr>
		<?php
		while($row = mysql_fetch_assoc($result)) {
		?>
			<tr>
				<td><?= $row['lastname'] ?>, <?= $row['firstname'] ?></td>
				<td><?= $row['date'] ?></td>
				<td><?= $row['time'] ?></td>
				<td><input type="button" value="View" onClick='location.href="<?= $_SERVER['PHP_SELF'] ?>?man=viewRedstars&amp;redstar=<?= $row['redstar_id'] ?>"'></td>
			</tr>
		<?php
		}
		?>
		</table>
		<?php
	}
}
?>